<?php

namespace App\Entity\Trade;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Entity\User;
use App\Repository\Trade\UserTradeRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=UserTradeRepository::class)
 */
class UserTrade
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"user"})
     */
    private $id;

    /**
     * @Common(cnName="用户",listType="text",editType="text",width="200")
     * @ORM\OneToOne(targetEntity=User::class, cascade={"persist", "remove"})
     * @ORM\JoinColumn(nullable=false)
     * @Groups({"user"})
     */
    private $user;

    /**
     * @Common(cnName="折扣率（%）",listType="text",editType="text")
     * @ORM\Column(type="float", nullable=true)
     * @Groups({"user"})
     */
    private $saleRate;

    /**
     * @Common(cnName="注册时间",listType="text",editType="text",width="200")
     * @ORM\Column(type="datetime",nullable=true)
     * @Groups({"user"})
     */
    private $createAt;

    /**
     * @Common(cnName="备注",listType="text",editType="text",width="")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"user"})
     */
    private $note;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(User $user): self
    {
        $this->user = $user;

        return $this;
    }

    public function getSaleRate(): ?float
    {
        return $this->saleRate;
    }

    public function setSaleRate(?float $saleRate): self
    {
        $this->saleRate = $saleRate;

        return $this;
    }

    public function getCreateAt(): ?\DateTimeInterface
    {
        return $this->createAt;
    }

    public function setCreateAt(\DateTimeInterface $createAt): self
    {
        $this->createAt = $createAt;

        return $this;
    }

    public function getNote(): ?string
    {
        return $this->note;
    }

    public function setNote(?string $note): self
    {
        $this->note = $note;

        return $this;
    }
}
